import type { HotelData } from "../../types/DataTypes";
import { HotelDAO } from "../../DAO";

export class HotelService {
    // ==================== 酒店操作 ====================

    // 新增酒店
    static async addHotel(hotel: HotelData): Promise<boolean> {
        return HotelDAO.addHotel(hotel);
    }

    // 获取所有酒店
    static async getAllHotels(): Promise<HotelData[]> {
        return HotelDAO.getAllHotels();
    }

    /*// 根据位置模糊查询酒店
    static async searchHotelsByLocation(location: string): Promise<HotelData[]> {
        return HotelDAO.searchHotelsByLocation(location);
    }

    // 根据价格范围查询酒店
    static async searchHotelsByPriceRange(minPrice: number, maxPrice: number): Promise<HotelData[]> {
        return HotelDAO.searchHotelsByPriceRange(minPrice, maxPrice);
    }*/

    // 更新酒店数据
    static async updateHotel(hotelData: HotelData): Promise<boolean> {
        return HotelDAO.updateHotel(hotelData);
    }

    // 可用房间数量+1
    static async incrementHotelAvailability(location: string): Promise<boolean> {
        return await HotelDAO.incrementHotelAvailability(location);
    }

    // 可用房间数量-1
    static async decrementHotelAvailability(location: string): Promise<boolean> {
        return await HotelDAO.decrementHotelAvailability(location);
    }

    // 删除酒店
    static async deleteHotel(location: string): Promise<boolean> {
        return HotelDAO.deleteHotel(location);
    }

    // 检查酒店是否存在
    static async hotelExists(location: string): Promise<boolean> {
        return HotelDAO.hotelExists(location);
    }

    // 检查酒店是否有可用房间
    static async checkHotelAvailability(location: string): Promise<boolean> {
        const hotel = await HotelDAO.getHotelByLocation(location);
        return hotel ? hotel.availRoom > 0 : false;
    }

    // 高级搜索（支持多个条件组合）
    static async advancedSearch(criteria: {
        location?: string;
        minPrice?: number;
        maxPrice?: number;
    }): Promise<HotelData[]> {
        return HotelDAO.advancedSearch(criteria);
    }
}